package com.management.vtribe.controller;

import com.management.vtribe.Bean.Tag;
import com.management.vtribe.config.Result;
import com.management.vtribe.config.Tool;
import com.management.vtribe.service.TagService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class TagController {
    @Autowired
    TagService tagService;

    @RequestMapping("/getAllTag")
    public List<Tag> getAllTag(){
        return tagService.getAllTag();
    }

    @RequestMapping("/updateUserTag")
    public Result updateUserTag(int uid,String tagIds){
        if(tagIds==null||tagIds.equals("")){return new Result(400,"修改失败！");}
        int[] tids = new Tool().toIntArray(tagIds);
        int res = tagService.updateUserTag(uid, tids);
        if(res!=0){
            return new Result(200,"修改成功！");
        }else{
            return new Result(400,"修改失败！");
        }
    }
}
